import React, { Component, cloneElement, createElement } from 'react'

const withLayout = (str) => (Cmp) => {
  return class extends Cmp {
    render() {
      const pnode = super.render()
      const type = pnode.props.children.type
      const ele = cloneElement(pnode, null, createElement(type, null, str))
      return (
        <>
          <div className="header">我是导航</div>
          {ele}
          <div className="footer">底部声明</div>
        </>
      )
    }
  }
}
export default withLayout
